<?php

/**
 * ECoreNetImapResponseType
 * ECoreNetImapResponseStatus
 *
 * @author Usenko Timur <usenko.timur@gmail.com>
 * @package net
 * @subpackage imap
 */

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapFetch
{
	const ALL = 'ALL';
	const FAST = 'FAST';
	const FULL = 'FULL';
	const BODY = 'BODY';
	const BODY_PEEK = 'BODY.PEEK';
	const BODYSTRUCTURE = 'BODYSTRUCTURE';
	const ENVELOPE = 'ENVELOPE';
	const FLAGS = 'FLAGS';
	const INTERNALDATE = 'INTERNALDATE';
	const RFC822 = 'RFC822';
	const RFC822_HEADER = 'RFC822.HEADER';
	const RFC822_SIZE = 'RFC822.SIZE';
	const RFC822_TEXT = 'RFC822.TEXT';
	const UID = 'UID';
	const INDEX = 'INDEX';

	/**
	 * @param array $aFetchItems
	 * @return array
	 */
	public static function ChangeFetchItemsBefourRequest(array $aFetchItems)
	{
		CCore::CheckTypes(array('$aFetchItems'));

		$aReturn = array(self::UID => new CCoreNetImapFetchItem(self::UID));
		foreach ($aFetchItems as $sFetchKey => $sFetchItem)
		{
			switch ($sFetchKey)
			{
				default:
					$aReturn[$sFetchKey] = $sFetchItem;
					break;
				case self::INDEX:
					break;
				case self::ALL:
					$aReturn[self::FLAGS] = new CCoreNetImapFetchItem(self::FLAGS);
					$aReturn[self::INTERNALDATE] = new CCoreNetImapFetchItem(self::INTERNALDATE);
					$aReturn[self::RFC822_SIZE] = new CCoreNetImapFetchItem(self::RFC822_SIZE);
					$aReturn[self::ENVELOPE] = new CCoreNetImapFetchItem(self::ENVELOPE);
					break;
				case self::FAST:
					$aReturn[self::FLAGS] = new CCoreNetImapFetchItem(self::FLAGS);
					$aReturn[self::INTERNALDATE] = new CCoreNetImapFetchItem(self::INTERNALDATE);
					$aReturn[self::RFC822_SIZE] = new CCoreNetImapFetchItem(self::RFC822_SIZE);
					break;
				case self::FULL:
					$aReturn[self::FLAGS] = new CCoreNetImapFetchItem(self::FLAGS);
					$aReturn[self::INTERNALDATE] = new CCoreNetImapFetchItem(self::INTERNALDATE);
					$aReturn[self::RFC822_SIZE] = new CCoreNetImapFetchItem(self::RFC822_SIZE);
					$aReturn[self::ENVELOPE] = new CCoreNetImapFetchItem(self::ENVELOPE);
					$aReturn[self::BODY] = new CCoreNetImapFetchItem(self::BODY);
					break;
			}
		}
		return $aReturn;
	}
}

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapResponseType
{
	const Unknown = 0;
	const Tagged = 1;
	const Untagged = 2;
	const Continuation = 3;
}

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapResponseStatus
{
	const Ok = 'OK';
	const No = 'NO';
	const Bad = 'BAD';
	const Bye = 'BYE';
	const Preauth = 'PREAUTH';
}

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapFolderStatus
{
	const MESSAGES = 'MESSAGES';
	const RECENT = 'RECENT';
	const UNSEEN = 'UNSEEN';
	const UIDNEXT = 'UIDNEXT';
	const UIDVALIDITY = 'UIDVALIDITY';
}

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapMessageStoreAction
{
	const SET_FLAGS = 'FLAGS';
	const SET_FLAGS_SILENT = 'FLAGS.SILENT';
	const ADD_FLAGS = '+FLAGS';
	const ADD_FLAGS_SILENT = '+FLAGS.SILENT';
	const REMOVE_FLAGS = '-FLAGS';
	const REMOVE_FLAGS_SILENT = '-FLAGS.SILENT';
}

/**
 * @package net
 * @subpackage imap
 */
class ECoreNetImapMessageFlag
{
	const RECENT = '\Recent';
	const SEEN = '\Seen';
	const DELETED = '\Deleted';
	const FLAGGED = '\Flagged';
	const ANSWERED = '\Answered';
	const DRAFT = '\Draft';
}
